local zhanyi = fk.CreateSkill{
    name = "XD__zhanyi",
}
Fk:loadTranslationTable{
    ["XD__zhanyi"] = "战意",
    [":XD__zhanyi"] = "当你使用黑色【杀】选择唯一目标后，你可以弃置其两张牌，令此【杀】无效且不计入使用次数；出牌阶段开始时，你可以失去1点体力，摸两张牌，然后本阶段限一次，当你使用【决斗】或红色【杀】对目标角色造成伤害时，此伤害+1。",
    ["#XD__zhanyi"] = "战意：是否弃置 %dest 两张牌，令%arg无效且不计入使用次数",
    ["#XD__zhanyi-discard"] = "战意：弃置 %dest 两张牌",
    ["#XD__zhanyi-invoke"] = "战意：是否失去1点体力并摸两张牌",
    ["@@XD__zhanyi-phase"] = "战意"
}

zhanyi:addEffect(fk.TargetSpecified, {
    anim_type = "control",
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(zhanyi.name) and data.card.trueName == "slash" and data.card.color == Card.Black
        and data:isOnlyTarget(data.to) and not data.to.dead and not data.to:isNude()
    end,
    on_cost = function (self, event, target, player, data)
        if player.room:askToSkillInvoke(player, {
            skill_name = zhanyi.name,
            prompt = "#XD__zhanyi::"..data.to.id..":"..data.card:toLogString(),
        }) then
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local cards = room:askToChooseCards(player, {
            target = data.to,
            flag = "he",
            max = 2,
            min = 2,
            skill_name = zhanyi.name,
            prompt = "#XD__zhanyi-discard::"..data.to.id,
        })
        room:throwCard(cards, zhanyi.name, data.to, player)
        data:cancelAllTarget()
        if not data.use.extraUse then
            data.use.extraUse = true
            player:addCardUseHistory(data.card.trueName, -1)
        end
    end,
})
zhanyi:addEffect(fk.EventPhaseStart, {
    anim_type = "drawcard",
    can_trigger = function (self, event, target, player, data)
        return target == player and player.phase == Player.Play and player:hasSkill(zhanyi.name)
    end,
    on_cost = function (self, event, target, player, data)
        if player.room:askToSkillInvoke(player, {
            skill_name = zhanyi.name,
            prompt = "#XD__zhanyi-invoke",
        }) then
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:loseHp(player, 1, zhanyi.name)
        player:drawCards(2, zhanyi.name)
        room:setPlayerMark(player, "@@XD__zhanyi-phase", 1)
    end,
})
zhanyi:addEffect(fk.DamageCaused, {
    is_delay_effect = true,
    anim_type = "offensive",
    can_trigger = function (self, event, target, player, data)
        return target == player and player:getMark("@@XD__zhanyi-phase") > 0 and data.card and
        (data.card.trueName == "duel" or (data.card.trueName == "slash" and data.card.color == Card.Red) )
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        player.room:setPlayerMark(player, "@@XD__zhanyi-phase", 0)
        data.damage = data.damage + 1
    end,
})

return zhanyi